{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tensor randint 约束范围的一种生成方法\n",
    "\n",
    "torch.randint()函数用于生成指定范围内的整数随机数。它接受三个参数：low（最小值）、high（最大值）和形状（shape）。返回的张量中的元素值将在 **[low, high)** 范围内。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "\"\"\"\n",
    "生成一个形状为(3, 4)的张量，元素值在[0, 10)之间\n",
    "相当有意思的是,这后面是一个元组的传递.\n",
    "\"\"\"\n",
    "\n",
    "tensor = torch.randint(0, 10, (3, 4))\n",
    "print(tensor)\n",
    "\n",
    "\"\"\"\n",
    "tensor([[9, 6, 1, 8],\n",
    "        [6, 0, 1, 2],\n",
    "        [5, 5, 6, 9]])\n",
    "\"\"\"\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
